package com.bizhibihui.ordermeal.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bizhibihui.ordermeal.entity.User;
import com.bizhibihui.ordermeal.util.CoreConst;
import lombok.AllArgsConstructor;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * 后台管理页面跳转控制器
 *
 */
@Controller
@AllArgsConstructor
public class AdminRenderController {


    /**
     * 后台首页
     */
    @RequestMapping("/back")
    public String index(Model model) {
        if (SecurityUtils.getSubject().isAuthenticated()) {
            User user = (User) SecurityUtils.getSubject().getPrincipal();
            model.addAttribute("user", user);
            return CoreConst.ADMIN_PREFIX + "index/index";
        }else{
            return "redirect:/login";
        }

    }

    /**
     * 工作台
     */
    @GetMapping("/workdest")
    public String workdest() {
        return CoreConst.ADMIN_PREFIX + "index/workdest";
    }

    /**
     * 用户列表入口
     */
    @GetMapping("/users")
    public String userList() {
        return CoreConst.ADMIN_PREFIX + "user/list";
    }

    /**
     * 角色列表入口
     */
    @GetMapping("/roles")
    public String roleList() {
        return CoreConst.ADMIN_PREFIX + "role/list";
    }

    /**
     * 权限列表入口
     */
    @GetMapping("/permissions")
    public String permissionList() {
        return CoreConst.ADMIN_PREFIX + "permission/list";
    }

    /**
     * 在线用户入口
     */
    @GetMapping("/online/users")
    public String onlineUsers() {
        return CoreConst.ADMIN_PREFIX + "onlineUsers/list";
    }



    /**
     * 分类
     */
    @GetMapping("/categories")
    public String categories() {
        return CoreConst.ADMIN_PREFIX + "category/list";
    }

    /**
     * 美食
     */
    @GetMapping("/foods")
    public String foods() {
        return CoreConst.ADMIN_PREFIX + "food/list";
    }

    /**
     * 标签
     */
    @GetMapping("/tags")
    public String tags() {
        return CoreConst.ADMIN_PREFIX + "tag/list";
    }



    /**
     * 美食
     */
    @GetMapping("/orders")
    public String orders() {
        return CoreConst.ADMIN_PREFIX + "order/list";
    }

    /**
     * 主题
     */
    @GetMapping("themes")
    public String themes() {
        return CoreConst.ADMIN_PREFIX + "systheme/list";
    }

}
